{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3b75f73e-6d1b-4a9e-935d-4a3d229bcc6a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "65b9b866-0960-40d1-8deb-4ebe1261d420",
   "metadata": {},
   "source": [
    "### Cross Product of two given vectors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1a98a54e-7a31-4575-84ec-c72c4aadb8a4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Function to take input array from user\n",
    "def np_array_frm_input(prompt):\n",
    "    try:\n",
    "        arr = list(map(int, input(prompt).split()))\n",
    "        np_array = np.array(arr, dtype=int)\n",
    "    except ValueError as e:\n",
    "        np_array = None\n",
    "        print(\"ERROR: Please enter only integers !!!\")\n",
    "        print(e)\n",
    "    return np_array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "f540a81d-f8e5-44c1-a280-ac96211ea7c4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Enter the first integer vector... 3\n",
      "Enter the second integer vector... 4 5\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ERROR: Vectors must be 2D pr 3D for computing cross-product !!!\n",
      "incompatible dimensions for cross product\n",
      "(dimension must be 2 or 3)\n"
     ]
    }
   ],
   "source": [
    "try:\n",
    "    vec1 = np_array_frm_input(\"Enter the first integer vector...\")\n",
    "    vec2 = np_array_frm_input(\"Enter the second integer vector...\")\n",
    "    print(f\"The cross product between {vec1} and {vec2} is {np.cross(vec1, vec2)}\")\n",
    "except ValueError as e:\n",
    "    print(\"ERROR: Vectors must be 2D pr 3D for computing cross-product !!!\")\n",
    "    print(e)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a7c915f7-e509-46e9-843a-c891fd2e64a3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
